import 'package:aio/aio.dart';
import 'package:flutter/cupertino.dart';
import 'package:app/generated/app_strings.dart';

///特殊加工
class SpecialClauses extends BaseBean {
  String? ScId = null;
  String? ScCode = null; //编号；条目信息里 ScCode+个数 为标题。
  String? ScTypeName = null; //类型
  String? ScIntro = null; //非标说明
  String? PriceUnitName = null; //单位
  String? PriceUnit = null; //PriceUnit = '02'，也就是PriceUnitName = '打孔' 显示在条目信息里。
  String? PriceTypeName = null; //片序
  List<Priceitem>? PriceitemList = null; //价格
  String? PriceUpTypeName = null; //上浮方式
  String? ScNum = null; //个数

  //获取价格
  String? getPrice(BuildContext context) {
    var str = "";
    var thickness = AppStrings.of(context).thickness; //厚度
    var mm = AppStrings.of(context).mm; //毫米
    var Price = AppStrings.of(context).Price; //价格
    PriceitemList?.forEach((element) {
      str += "$thickness" +
          element.Thickness +
          "$mm $Price" +
          element.Price +
          "\n";
    });
    return str.trim();
  }

  @override
  fromJson(Map<String, dynamic> json) {
    ScId = json['ScId']?.toString() ?? "";
    ScCode = json['ScCode']?.toString() ?? "";
    ScTypeName = json['ScTypeName']?.toString() ?? "";
    ScIntro = json['ScIntro']?.toString() ?? "";
    PriceUnitName = json['PriceUnitName']?.toString() ?? "";
    PriceUnit = json['PriceUnit']?.toString() ?? "";
    PriceTypeName = json['PriceTypeName']?.toString() ?? "";
    PriceitemList =
        setGenericFromJson(json, 'PriceitemList', <Priceitem>[], Priceitem());
    PriceUpTypeName = json['PriceUpTypeName']?.toString() ?? "";
    ScNum = json['ScNum']?.toString() ?? "";
  }

  @override
  instance() {
    // TODO: implement instance
    return SpecialClauses();
  }

  @override
  Map<String, dynamic> toJson() {
    var map = <String, dynamic>{};
    map["ScId"] = ScId;
    map["ScCode"] = ScCode;
    map["ScTypeName"] = ScTypeName;
    map["ScIntro"] = ScIntro;
    map["PriceUnitName"] = PriceUnitName;
    map["PriceUnit"] = PriceUnit;
    map["PriceTypeName"] = PriceTypeName;
    map["PriceitemList"] = PriceitemList;
    map["PriceUpTypeName"] = PriceUpTypeName;
    map["ScNum"] = ScNum;
    return map;
  }
}

//特殊加工里面的 价格
class Priceitem extends BaseBean {
  String Thickness = ""; //厚度
  String Price = ""; //价格
  String SynCode1 = ""; //编码

  @override
  fromJson(Map<String, dynamic> json) {
    // TODO: implement fromJson
    Thickness = json['Thickness']?.toString() ?? "";
    Price = json['Price']?.toString() ?? "";
    SynCode1 = json['SynCode1']?.toString() ?? "";
  }

  @override
  instance() {
    // TODO: implement instance
    return Priceitem();
  }

  @override
  Map<String, dynamic> toJson() {
    // TODO: implement toJson
    var map = <String, dynamic>{};
    map["Thickness"] = Thickness;
    map["Price"] = Price;
    map["SynCode1"] = SynCode1;
    return map;
  }
}
